home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacFormat España 15
/
macformat_15.iso
/
C de cerca
/
Codewarrior Lite
/
MacOS Support
/
Headers
/
ANSI Headers
/
ios
< prev
next >
Wrap
Text File
|
1995-12-29
|
5KB
|
198 lines
// ios standard header
#ifndef _IOS_
#define _IOS_
#include <exception>
#if __MWERKS__
#pragma options align=mac68k
#if __CFM68K__ && __USING_IMPORTED_ANSI__
#pragma import on
#endif
#endif
// I/O exception macros
#if _CATCH_IO_EXCEPTIONS
#define _TRY_IO_BEGIN _TRY_BEGIN
#define _CATCH_IO_END _CATCH_ALL \
setstate(badbit); _RERAISE; _CATCH_END
#define _CATCH_IO_(x) _CATCH_ALL \
(x).setstate(ios::badbit); _RERAISE; _CATCH_END
#else
#define _TRY_IO_BEGIN {
#define _CATCH_IO_END }
#define _CATCH_IO_(x) }
#endif
class ostream; class streambuf;
// class ios
class ios {
public:
// class failure
class failure : public xmsg {
public:
failure(const char *_X = 0, const char *_Y = 0,
const char *_Z = 0)
: xmsg(_X, _Y, _Z) {};
virtual ~failure();
protected:
virtual void do_raise();
};
enum _Fmtflags {skipws = 0x0001, unitbuf = 0x0002,
uppercase = 0x0004, showbase = 0x0008,
showpoint = 0x0010, showpos = 0x0020,
left = 0x0040, right = 0x0080, internal = 0x0100,
dec = 0x0200, oct = 0x0400, hex = 0x0800,
scientific = 0x1000, fixed = 0x2000,
adjustfield = 0x01c0, basefield = 0x0e00,
floatfield = 0x3000, _Fmtmask = 0x3fff, _Fmtzero = 0};
enum _Iostate {goodbit = 0x0, eofbit = 0x1,
failbit = 0x2, badbit = 0x4, _Statmask = 0x7};
enum _Openmode {in = 0x01, out = 0x02, ate = 0x04,
app = 0x08, trunc = 0x10, binary = 0x20};
enum seekdir {beg = 0, cur = 1, end = 2};
_BITMASK(_Fmtflags, fmtflags);
_BITMASK(_Iostate, iostate);
_BITMASK(_Openmode, openmode);
typedef short io_state, open_mode, seek_dir;
enum _Uninitialized {_Noinit};
// class Init
class Init {
public:
Init();
~Init();
private:
static int _Init_cnt;
};
// class _Iosarray
class _Iosarray {
public:
_Iosarray(int _Idx, _Iosarray *_Link = 0)
: _Next(_Link), _Index(_Idx), _Lo(0), _Vp(0) {}
_Iosarray *_Next;
int _Index;
long _Lo;
void *_Vp;
};
ios(streambuf *_S)
{init(_S); }
ios(const ios& _R)
{init(0), *this = _R; }
ios& operator=(const ios&);
virtual ~ios();
operator void *() const
{return (void *)(!*this ? 0 : this); }
_Bool operator!() const
{return (((int)_State
& ((int)failbit|(int)badbit)) != 0); }
ios& copyfmt(const ios&);
ostream *tie() const
{return (_Tiestr); }
ostream *tie(ostream *);
streambuf *rdbuf() const
{return (_Sb); }
streambuf *rdbuf(streambuf *);
iostate rdstate() const
{return (_State); }
void clear(iostate = goodbit);
void clear(io_state _St)
{clear((iostate)_St); }
void setstate(iostate _St)
{clear((iostate)((int)_State | (int)_St)); }
void setstate(io_state _St)
{setstate((iostate)_St); }
_Bool good() const
{return (_State == goodbit); }
_Bool eof() const
{return ((int)_State & (int)eofbit); }
_Bool fail() const
{return ((int)_State
& ((int)badbit | (int)failbit)); }
_Bool bad() const
{return ((int)_State & (int)badbit); }
iostate exceptions() const
{return (_Except); }
void exceptions(iostate);
void exceptions(io_state _St)
{exceptions((iostate)_St); }
fmtflags flags() const
{return (_Fmtfl); }
fmtflags flags(fmtflags);
fmtflags setf(fmtflags);
fmtflags setf(fmtflags, fmtflags);
void unsetf(fmtflags);
int fill() const
{return (_Fillch); }
int fill(int);
int precision() const
{return (_Prec); }
int precision(int);
int width() const
{return (_Wide); }
int width(int);
static int xalloc()
{return (_Index++); }
long& iword(int _Idx)
{return (_Findarr(_Idx)._Lo); }
void *& pword(int _Idx)
{return (_Findarr(_Idx)._Vp); }
protected:
ios()
{init(0); }
ios(_Uninitialized)
{}
void init(streambuf *);
private:
streambuf *_Sb;
ostream *_Tiestr;
iostate _State, _Except;
fmtflags _Fmtfl;
int _Prec, _Wide;
char _Fillch;
static int _Index;
_Iosarray *_Arr;
_Iosarray& _Findarr(int);
void _Tidy();
};
_BITMASK_OPS(ios::_Fmtflags)
_BITMASK_OPS(ios::_Iostate)
_BITMASK_OPS(ios::_Openmode)
// manipulators
ios& dec(ios&);
ios& fixed(ios&);
ios& hex(ios&);
ios& internal(ios&);
ios& left(ios&);
ios& noshowbase(ios&);
ios& noshowpoint(ios&);
ios& noshowpos(ios&);
ios& noskipws(ios&);
ios& nouppercase(ios&);
ios& oct(ios&);
ios& right(ios&);
ios& scientific(ios&);
ios& showbase(ios&);
ios& showpoint(ios&);
ios& showpos(ios&);
ios& skipws(ios&);
ios& uppercase(ios&);
#if __MWERKS__
#if __CFM68K__ && __USING_IMPORTED_ANSI__
#pragma import reset
#endif
#pragma options align=reset
#endif
#endif
/*
* Copyright (c) 1994 by P.J. Plauger. ALL RIGHTS RESERVED.
* Consult your license regarding permissions and restrictions.
*/
/* Change log:
*94Oct03 Version received from PlumHall
*94Oct07 Inserted MW changes.
*/